home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / CNews / Source / relay / article.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-23  |  1.1 KB  |  58 lines

  1. /*
  2.  * article creation and destruction
  3.  */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <sys/types.h>
  7. #include "libc.h"
  8. #include "news.h"
  9. #include "headers.h"
  10. #include "article.h"
  11.  
  12. void
  13. artinit(art)
  14. register struct article *art;
  15. {
  16.     static long uniqno = 0;
  17.  
  18.     art->a_status = ST_OKAY;
  19.     hdrinit(&art->h);
  20.     art->a_haccum = NULL;
  21.     art->a_hnext = NULL;
  22.     art->a_hpalloced = 0;
  23.     art->a_hpused = 0;
  24.     art->a_hptrs = NULL;
  25.     art->a_hbytesleft = 0;
  26.     art->a_files = NULL;
  27.     art->a_tmpf = NULL;
  28.     art->a_artf = NULL;
  29.     art->a_unlink = NO;
  30.     art->a_filed = NO;
  31.     art->a_xref = NO;
  32.     art->a_blvmax = NO;
  33.     art->a_charswritten = 0;
  34.     art->a_unread = 0;
  35.     art->a_id = uniqno++;
  36.     art->a_badhdr = NO;
  37. }
  38.  
  39. void
  40. artfree(art)
  41. register struct article *art;
  42. {
  43.     freeheaders(&art->h);
  44.     /* a_haccum is currently not malloced */
  45.     art->a_hptrs = NULL;        /* don't free a_hptrs; see hdrsave() */
  46.     nnfree(&art->a_files);
  47.     nnfree(&art->a_tmpf);
  48.     if (art->a_artf != NULL) {
  49.         (void) fprintf(stderr, "%s: a_artf still open in artfree()\n",
  50.             progname);
  51.         if (nfclose(art->a_artf) == EOF) {
  52.             art->a_status |= ST_DROPPED;
  53.             warning("error closing %s", art->a_tmpf);
  54.         }
  55.         art->a_artf = NULL;
  56.     }
  57. }
  58.